package xj.graph2d.app.prop;

import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Graphics;

import javax.swing.Icon;

import xj.graph2d.DrawAttr;

public class ColorIcon implements Icon {

  protected Dimension dim = new Dimension(16, 16);

  protected Color color = DrawAttr.getDefaultPenColor();

  public ColorIcon() {
  }

  public Color getColor() {
    return color;
  }

  public void setColor(Color color) {
    this.color = color;
  }

  public void paintIcon(Component c, Graphics g, int x, int y) {
    Color oldColor = g.getColor();
    g.setColor(color);
    g.fill3DRect(x, y, 16, 16, true);
    g.setColor(oldColor);
  }

  public int getIconWidth() {
    return dim.width;
  }

  public int getIconHeight() {
    return dim.height;
  }

}
